package com.tledu.stu_manager.controller.login; /**
 *
 */

import com.tledu.stu_manager.constant.SessionConstant;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "LogoutServlet", urlPatterns = "/logout")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //首先将session中的数据清除
        request.getSession().setAttribute(SessionConstant.CURRENT_LOGIN_USER, null);
        //跳转到登录界面
        response.sendRedirect(request.getContextPath() + "/login.jsp");
    }
}
